<?php
class IndexController extends Zend_Controller_Action 
{
    public function indexAction() 
    {
		$this->view->navTitle = $this->view->translate('home');        
        $conference = $this->getActiveConference(); 
        if($this->view->lang == 'en'){
            $this->view->conference_name = $conference->name_en;
        }else{
            $this->view->conference_name = $conference->name_mk;
        }
    }
	public function languageAction(){
	}
	
	public function pcAction(){
        $this->view->navTitle = $this->view->translate('pc');
	}
	public function tcAction(){
        $this->view->navTitle = $this->view->translate('tc');
	}
	public function scopeAction(){
        $this->view->navTitle = $this->view->translate('scope');
	}
	public function topicsAction(){
        $this->view->navTitle = $this->view->translate('ct');
        $this->view->categories = $this->getCategories();        
	}
    private function getCategories(){
		require_once APPLICATION_PATH . '/models/Category.php';
      	$model = new Model_Category();
      	return $model->fetchEntries();
    } 
	public function languagesAction(){
        $this->view->navTitle = $this->view->translate('lang');
	}
	public function proceedingsAction(){
        $this->view->navTitle = $this->view->translate('proc');
	}
	public function regfeeAction(){
        $this->view->navTitle = $this->view->translate('regfee');
	}
	public function taAction(){
        $this->view->navTitle = $this->view->translate('ta');
	}
    public function ocAction(){        
        $this->view->navTitle = $this->view->translate('oc');
	}
    public function scouncilAction(){        
        $this->view->navTitle = $this->view->translate('scouncil');
	}
    public function scAction(){        
        $this->view->navTitle = $this->view->translate('sc');
	}
	public function societyAction(){
        if($this->view->lang == 'en'){
            $this->view->navTitle = $this->view->translate('society');
        }else{
            $this->_helper->redirector('societymk');
        }
	}
    public function societymkAction(){
        $this->view->navTitle = $this->view->translate('society');
	if($this->view->lang == 'en'){
            $this->_helper->redirector('society');
        }
	}
    public function deadlineAction(){
        $this->view->navTitle = $this->view->translate('deadline');
        $conference = $this->getActiveConference();  
        $date = new Zend_Date($conference->date_submition, Zend_Date::ISO_8601);        
        $this->view->ps = $date->toString('dd.MM.YYYY');
        $date = new Zend_Date($conference->date_notification, Zend_Date::ISO_8601);        
        $this->view->an = $date->toString('dd.MM.YYYY');
        $date = new Zend_Date($conference->date_final, Zend_Date::ISO_8601);        
        $this->view->fs = $date->toString('dd.MM.YYYY');
	}
	public function prevAction(){
        $this->view->navTitle = $this->view->translate('prev');
	}
	public function langAction(){
		$lang = Zend_Registry::get('lang');
		if($lang == 'mk'){
			setcookie('lang', 'en', 0, '/');
		}else{
			setcookie('lang', 'mk', 0, '/');
		}
        $this->_helper->redirector($lang, 'index', 'index');
	}
	public function sitemapAction(){
    $this->view->navTitle = $this->view->translate('sitemap');
	}
    
    public function testAction(){
        $to = 'tomce.delev@gmail.com';
	    $subject = 'Test mail from etai';
	    $message = 'This is a test mail.';
	    // set headers as per your requirements.
	    $headers = 'From: test@etai.feit.ukim.edu.mk' . "\r\n";
	 
	    if (mail($to, $subject, $message, $headers)) {
		    echo 'Message sent!';
	    }
	    else
	    {
		    echo 'Message failed, contact webmaster for more info!';
	    }
        die();
    }
    public function testdateAction(){
      echo date('Y-m-d H:i:s', time());
      die();
    }
    public function testmailAction(){
        $this->confirmationMail(5, 434324234,  'Tomce', 'Delev', 'ETAI - 2009', 'tomce.delev@gmail.com');
        die();
    }     
    
    private function getActiveConference(){
		require_once APPLICATION_PATH . '/models/Conference.php';
      	$model = new Model_Conference();
      	return $model->getActive();
    }     

}
